/** 
* 文 件 名:SportsAdviceActivity.java
* Copyright (C) 2007-2012:杭州希禾信息技术有限公司 版权所有 
* 创 建 人:HuHao
* 日    期:2012-4-5 下午9:14:26
* 修 改 人: 
* 日   期:
* 修改描述:
* 描   述:TODO
*/
package net.seehealth.healthpad.ui;

import net.seehealth.healthpad.R;
import android.os.Bundle;
import android.text.Html;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * @className SportsAdviceActivity
 * @author HuHao
 * @description TODO
 * @date 2012-4-5 下午9:14:26
 */
public class SportsAdviceActivity extends BaseActivity {

	private TextView mBmi1View;
	private TextView mBmi2View;
	private TextView mBmi3View;
	private TextView mBmi4View;
	private TextView mBmi5View;
	private TextView mBmi6View;

	/** 体重指数label **/
	private TextView mBmiLabel;
	/** 体重重量label **/
	private TextView mKGLabel;

	/** 正常指数 **/
	private TextView mNormalBmiView;
	
	/** 当前体重指数 **/
	private TextView mBmiView;

	/** 当前体重 **/
	private TextView mKGView;
	
	/** 标准体重 **/
	private TextView mStandardKGView;
	
	/** 每日运动 **/
	private TextView mEverydaySports1View;
	private TextView mEverydaySports2View;
	private TextView mEverydaySports3View;
	private TextView mEverydaySports4View;
	
	/** 运动记录 **/
	private TextView mSportsRecordView;
	
	/** 常见运动 **/
	private TextView mUsualSportView;
	
	/** 标题 **/
	private TextView mTitleView;
	
	/** 标准BMI游标 **/
	private ImageView mBMICursorBtn;
	
	/** 标准KG游标 **/
	private ImageView mKGCursorBtn;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		// 初始化数据
		initData();

		// 初始化视图
		initView();

	}


	/**
	 * 初始化数据
	 * @author HuHao
	 * @date 2012-4-5 下午9:59:19
	 */
	private void initData() {

	}

	/**
	 * 初始化视图
	 * @author HuHao
	 * @date 2012-4-5 下午9:59:12
	 */
	private void initView() {

		setContentView(R.layout.main_sports_advice);

		// 返回按钮
		((ImageButton)findViewById(R.id.ib_common_back)).setOnClickListener(mClickListener);

		// 标题
		mTitleView = (TextView)findViewById(R.id.tv_common_title);
		mTitleView.setText("运动建议");

        //每日运动
        TextView esl = (TextView)findViewById(R.id.tv_everyday_sports_label);
        esl.getPaint().setFakeBoldText(true);

        // 偏瘦
        mBmi1View = (TextView)findViewById(R.id.tv_bmi1);
        mBmi1View.getPaint().setFakeBoldText(true);
        // 正常
        mBmi2View = (TextView)findViewById(R.id.tv_bmi2);
        mBmi2View.getPaint().setFakeBoldText(true);
        // 超重
        mBmi3View = (TextView)findViewById(R.id.tv_bmi3);
        mBmi3View.getPaint().setFakeBoldText(true);
        // 肥胖
        mBmi4View = (TextView)findViewById(R.id.tv_bmi4);
        mBmi4View.getPaint().setFakeBoldText(true);
        // 超胖
        mBmi5View = (TextView)findViewById(R.id.tv_bmi5);
        mBmi5View.getPaint().setFakeBoldText(true);

        mBmi6View = (TextView)findViewById(R.id.tv_bmi_6);
        mBmi6View.getPaint().setFakeBoldText(true);

        mBmiLabel = (TextView)findViewById(R.id.tv_bmi_label);
        mBmiLabel.getPaint().setFakeBoldText(true);
        mKGLabel = (TextView)findViewById(R.id.tv_kg_label);
        mKGLabel.getPaint().setFakeBoldText(true);

        mNormalBmiView = (TextView) findViewById(R.id.tv_bmi_normal);
        mBmiView = (TextView) findViewById(R.id.tv_mybmi);
        mKGView = (TextView) findViewById(R.id.tv_mykg);
        mStandardKGView = (TextView) findViewById(R.id.tv_mystandard_kg);
        
        mEverydaySports1View = (TextView) findViewById(R.id.tv_everyday_sports1);
        mEverydaySports2View = (TextView) findViewById(R.id.tv_everyday_sports2);
        mEverydaySports3View = (TextView) findViewById(R.id.tv_everyday_sports3);
        mEverydaySports4View = (TextView) findViewById(R.id.tv_everyday_sports4);
        
        mSportsRecordView = (TextView) findViewById(R.id.tv_sports_record);
        mSportsRecordView.setOnClickListener(mClickListener);
        mUsualSportView = (TextView) findViewById(R.id.tv_usual_sport);
        mUsualSportView.setOnClickListener(mClickListener);
        
        mBMICursorBtn = (ImageView) findViewById(R.id.iv_bmi_cursor);
        mKGCursorBtn = (ImageView) findViewById(R.id.iv_kg_cursor);
       
        Animation am = new TranslateAnimation(50, 420, 0, 0);
        am.setDuration(3000);
        am.setFillAfter(true);
        am.setInterpolator(mContext, android.R.anim.overshoot_interpolator);
        mBMICursorBtn.setAnimation(am);
        am.startNow();

        am = new TranslateAnimation(50, 440, 0, 0);
        am.setDuration(3070);
        am.setFillAfter(true);
        am.setInterpolator(mContext, android.R.anim.overshoot_interpolator);
        mKGCursorBtn.setAnimation(am);
        am.startNow();

        String myBmi = mBmiView.getText().toString();
        myBmi = myBmi.replace("%", getStringData("26.20", 25, "#669900"));
        mBmiView.setText(Html.fromHtml(myBmi));

        String myKG = mKGView.getText().toString();
        myKG = myKG.replace("%", getStringData("75.5", 25, "#ff9900"));
        mKGView.setText(Html.fromHtml(myKG));

        String myStandardKG = mStandardKGView.getText().toString();
        myStandardKG = myStandardKG.replace("%", getStringData("54.7kg~71.0kg", 25, "#669900"));
        mStandardKGView.setText(Html.fromHtml(myStandardKG));
        
        String yoga = mEverydaySports1View.getText().toString();
        yoga = yoga.replace("%", "<b><font color=#333333>" + "瑜伽" + "</font></b><p>");
        yoga = yoga.replace("$", "<font color=#2388ce>" + "30分钟" + "</font>");
        mEverydaySports1View.setText(Html.fromHtml(yoga));

        String badminton = mEverydaySports2View.getText().toString();
        badminton = badminton.replace("%", "<b><font color=#333333>" + "羽毛球" + "</font></b><p>");
        badminton = badminton.replace("$", "<font color=#2388ce>" + "30分钟" + "</font>");
        mEverydaySports2View.setText(Html.fromHtml(badminton));

        String situp = mEverydaySports3View.getText().toString();
        situp = situp.replace("%", "<b><font color=#333333>" + "仰卧起坐" + "</font></b><p>");
        situp = situp.replace("$", "<font color=#2388ce>" + "5分钟" + "</font>");
        mEverydaySports3View.setText(Html.fromHtml(situp));
        
        String playpiano = mEverydaySports4View.getText().toString();
        playpiano = playpiano.replace("%", "<b><font color=#333333>" + "弹钢琴" + "</font></b><p>");
        playpiano = playpiano.replace("$", "<font color=#2388ce>" + "60分钟" + "</font>");
        mEverydaySports4View.setText(Html.fromHtml(playpiano));
	}

	/**
	 * 点击事件
	 */
	View.OnClickListener mClickListener = new View.OnClickListener() {

		@Override
		public void onClick(View v) {
			switch (v.getId()) {
			case R.id.ib_common_back:		// 关闭按钮
				finish();
				break;
			case R.id.tv_sports_record:		// 运动记录
				break;

			case R.id.tv_usual_sport:		// 常见运动
				break;

			default:
				break;
			}
		}
	};
	
	/**
	 * 获得有属性值的值
	 * @param value 显示的值
	 * @param size 字体大小
	 * @param color 字体颜色
	 * @return 
	 */
	private String getStringData(String value, int size, String color){
		 return "<i><u><font color= " + color + "  size='" + size +"'>" + value + "</font></u></i>";
	}

}
